package com.xbongbong.pro.businessrulelog.pojo;

import com.xbongbong.paas.enums.BusinessRuleExecuteEnum;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.form.pojo.RuleTargetPojo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2020/6/19 11:30
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class BusinessRuleLogSaveDTO extends BaseDTO {

    private static final long serialVersionUID = 4073006125830930641L;

    private Integer saasMark;

    private Integer businessType;

    private Long formId;

    private Long dataId;

    private Long logId;

    private RuleTargetPojo target;

    private Integer operationType;

    /**
     * 出错信息
     */
    private String message;

    /**
     * 出错原因（1：自身错误；2：被动错误；3：数据量过大）
     * @see BusinessRuleExecuteEnum
     *
     */
    private Integer reason;

    private String redisKey;

    private Integer businessRuleSize;

    private Long businessRuleInfoId;

    /**
     * 执行类型（1：生效；2：失效）
     */
    private Integer businessRuleType;


    public BusinessRuleLogSaveDTO() {
    }

    public BusinessRuleLogSaveDTO(Integer saasMark, Integer businessType, Long formId, Long dataId, String corpid, UserVO userVO, String platform,
                                  String httpHeader, String browserInfo, String ip, String locale
    ) {
        this.saasMark = saasMark;
        this.businessType = businessType;
        this.formId = formId;
        this.dataId = dataId;
        setCorpid(corpid);
        setLoginUser(userVO);
        setUserId(userVO.getUserId());
        setLoginUserName(userVO.getName());
        setPlatform(platform);
        setHttpHeader(httpHeader);
        setBrowserInfo(browserInfo);
        setIp(ip);
        setLocale(locale);
    }

    public BusinessRuleLogSaveDTO(Integer saasMark, Integer businessType, Long formId, Long dataId, Integer businessRuleType, String corpid, UserVO userVO, String platform,
                                  String httpHeader, String browserInfo, String ip, String locale
                                  ) {
        this.saasMark = saasMark;
        this.businessType = businessType;
        this.formId = formId;
        this.dataId = dataId;
        this.businessRuleType = businessRuleType;
        setCorpid(corpid);
        setLoginUser(userVO);
        setUserId(userVO.getUserId());
        setLoginUserName(userVO.getName());
        setPlatform(platform);
        setHttpHeader(httpHeader);
        setBrowserInfo(browserInfo);
        setIp(ip);
        setLocale(locale);
    }

    public BusinessRuleLogSaveDTO(Integer saasMark, Integer businessType, Long formId, Long dataId, String corpid, UserVO userVO, String platform,
                                  String httpHeader, String browserInfo, Integer businessRuleType,RuleTargetPojo target, String ip, String locale) {
        this.saasMark = saasMark;
        this.businessType = businessType;
        this.formId = formId;
        this.dataId = dataId;
        this.businessRuleType = businessRuleType;
        this.target = target;
        setCorpid(corpid);
        setLoginUser(userVO);
        setUserId(userVO.getUserId());
        setLoginUserName(userVO.getName());
        setPlatform(platform);
        setHttpHeader(httpHeader);
        setBrowserInfo(browserInfo);
        setIp(ip);
        setLocale(locale);
    }
}
